package cn.mzy.feign;

import cn.mzy.domain.User;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @Package: cn.mzy.feign
 * @ClassName: UserServiceFallbackFactory
 * @Date:2022/11/9 14:37
 * @Description:
 */
// 交给spring管理
@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            // 返回托底数据
            @Override
            public User getUserById(Long id) {
                return new User(0L, "连接失败", "请稍后再试");
            }
        };
    }
}
